home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / drivers / phozon.c < prev    next >
C/C++ Source or Header  |  2000-04-04  |  13KB  |  355 lines

  1. /***************************************************************************
  2.  
  3. Phozon (Namco 1983)
  4.  
  5.     Manuel Abadia (emumanu@hotmail.com)
  6.  
  7. Phozon Memory Map (preliminary)
  8.  
  9. CPU #1: (MAIN CPU)
  10. 0000-03ff   video RAM
  11. 0400-07ff   color RAM
  12. 0800-1fff   shared RAM with CPU #2
  13. 4040-43ff   shared RAM with CPU #3
  14. 4800-480f    custom IO chip #1
  15. 4810-481f    custom IO chip #2
  16. 5000-5009    ???
  17. 500a-500b    CPU #3 enable
  18. 500c-500d    CPU #2 enable
  19. 500e-500f    ???
  20. 7000        watchdog reset
  21. 8000-9fff    ROM
  22. a000-bfff   ROM
  23. c000-dfff   ROM
  24. e000-ffff   ROM
  25.  
  26. CPU #2: (SUB CPU)
  27. 0000-03ff   video RAM (shared with CPU #1)
  28. 0400-07ff   color RAM (shared with CPU #1)
  29. 0800-1fff   shared RAM with CPU #1
  30. a000-a7ff   RAM
  31. e000-ffff   ROM
  32.  
  33. CPU #3: (SOUND CPU)
  34. 0000-0040   sound registers
  35. 0040-03ff   shared RAM with CPU #1
  36. e000-ffff   ROM
  37.  
  38. TODO: cocktail mode
  39.  
  40. ***************************************************************************/
  41.  
  42. #include "driver.h"
  43. #include "vidhrdw/generic.h"
  44.  
  45. extern unsigned char *phozon_snd_sharedram;
  46. extern unsigned char *phozon_spriteram;
  47. extern unsigned char *phozon_customio_1, *phozon_customio_2;
  48. extern unsigned char *mappy_soundregs;
  49.  
  50. /* memory functions */
  51. READ_HANDLER( phozon_spriteram_r );
  52. READ_HANDLER( phozon_snd_sharedram_r );
  53. WRITE_HANDLER( phozon_spriteram_w );
  54. WRITE_HANDLER( phozon_snd_sharedram_w );
  55.  
  56. /* custom IO chips & CPU functions */
  57. READ_HANDLER( phozon_customio_1_r );
  58. READ_HANDLER( phozon_customio_2_r );
  59. WRITE_HANDLER( phozon_customio_1_w );
  60. WRITE_HANDLER( phozon_customio_2_w );
  61. WRITE_HANDLER( phozon_cpu2_enable_w );
  62. WRITE_HANDLER( phozon_cpu3_enable_w );
  63. WRITE_HANDLER( phozon_cpu3_reset_w );
  64. extern void phozon_init_machine(void);
  65.  
  66. /* video functions */
  67. extern int phozon_vh_start( void );
  68. extern void phozon_vh_stop( void );
  69. extern void phozon_vh_convert_color_prom(unsigned char *palette, unsigned short *colortable,const unsigned char *color_prom);
  70. extern void phozon_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh);
  71.  
  72.     /* CPU 1 (MAIN CPU) read addresses */
  73. static struct MemoryReadAddress readmem_cpu1[] =
  74. {
  75.     { 0x0000, 0x03ff, videoram_r },            /* video RAM */
  76.     { 0x0400, 0x07ff, colorram_r },                                        /* color RAM */
  77.     { 0x0800, 0x1fff, phozon_spriteram_r },            /* shared RAM with CPU #2/sprite RAM*/
  78.     { 0x4040, 0x43ff, phozon_snd_sharedram_r },  /* shared RAM with CPU #3 */
  79.     { 0x4800, 0x480f, phozon_customio_1_r },        /* custom I/O chip #1 interface */
  80.     { 0x4810, 0x481f, phozon_customio_2_r },        /* custom I/O chip #2 interface */
  81.     { 0x8000, 0xffff, MRA_ROM },                                        /* ROM */
  82.     { -1 }                                                                /* end of table */
  83. };
  84.  
  85.     /* CPU 1 (MAIN CPU) write addresses */
  86. static struct MemoryWriteAddress writemem_cpu1[] =
  87. {
  88.     { 0x0000, 0x03ff, videoram_w, &videoram, &videoram_size },                /* video RAM */
  89.     { 0x0400, 0x07ff, colorram_w, &colorram },  /* color RAM */
  90.     { 0x0800, 0x1fff, phozon_spriteram_w, &phozon_spriteram },        /* shared RAM with CPU #2/sprite RAM*/
  91.     { 0x4000, 0x403f, MWA_RAM },                /* initialized but probably unused */
  92.     { 0x4040, 0x43ff, phozon_snd_sharedram_w, &phozon_snd_sharedram }, /* shared RAM with CPU #3 */
  93.     { 0x4800, 0x480f, phozon_customio_1_w, &phozon_customio_1 },    /* custom I/O chip #1 interface */
  94.     { 0x4810, 0x481f, phozon_customio_2_w, &phozon_customio_2 },    /* custom I/O chip #2 interface */
  95.     { 0x4820, 0x483f, MWA_RAM },                /* initialized but probably unused */
  96.     { 0x5000, 0x5007, MWA_NOP },                /* ??? */
  97.     { 0x5008, 0x5008, phozon_cpu3_reset_w },    /* reset SOUND CPU? */
  98.     { 0x5009, 0x5009, MWA_NOP },                /* ??? */
  99.     { 0x500a, 0x500b, phozon_cpu3_enable_w },    /* SOUND CPU enable */
  100.     { 0x500c, 0x500d, phozon_cpu2_enable_w },    /* SUB CPU enable */
  101.     { 0x500e, 0x500f, MWA_NOP },                /* ??? */
  102.     { 0x7000, 0x7000, watchdog_reset_w },         /* watchdog reset */
  103.     { 0x8000, 0xffff, MWA_ROM },                /* ROM */
  104.     { -1 }                                        /* end of table */
  105. };
  106.  
  107.     /* CPU 2 (SUB CPU) read addresses */
  108. static struct MemoryReadAddress readmem_cpu2[] =
  109. {
  110.     { 0x0000, 0x03ff, videoram_r },            /* video RAM */
  111.     { 0x0400, 0x07ff, colorram_r },            /* color RAM */
  112.     { 0x0800, 0x1fff, phozon_spriteram_r },    /* shared RAM with CPU #1/sprite RAM*/
  113.     { 0xa000, 0xa7ff, MRA_RAM },            /* RAM */
  114.     { 0xe000, 0xffff, MRA_ROM },            /* ROM */
  115.     { -1 }                                    /* end of table */
  116. };
  117.  
  118.     /* CPU 2 (SUB CPU) write addresses */
  119. static struct MemoryWriteAddress writemem_cpu2[] =
  120. {
  121.     { 0x0000, 0x03ff, videoram_w },            /* video RAM */
  122.     { 0x0400, 0x07ff, colorram_w },            /* color RAM */
  123.     { 0x0800, 0x1fff, phozon_spriteram_w },    /* shared RAM with CPU #1/sprite RAM*/
  124.     { 0xa000, 0xa7ff, MWA_RAM },            /* RAM */
  125.     { 0xe000, 0xffff, MWA_ROM },            /* ROM */
  126.     { -1 }                                    /* end of table */
  127. };
  128.  
  129.     /* CPU 3 (SOUND CPU) read addresses */
  130. static struct MemoryReadAddress readmem_cpu3[] =
  131. {
  132.     { 0x0000, 0x003f, MRA_RAM },                /* sound registers */
  133.     { 0x0040, 0x03ff, phozon_snd_sharedram_r }, /* shared RAM with CPU #1 */
  134.     { 0xe000, 0xffff, MRA_ROM },                /* ROM */
  135.     { -1 }                                        /* end of table */
  136. };
  137.  
  138.     /* CPU 3 (SOUND CPU) write addresses */
  139. static struct MemoryWriteAddress writemem_cpu3[] =
  140. {
  141.     { 0x0000, 0x003f, mappy_sound_w, &mappy_soundregs },/* sound registers */
  142.     { 0x0040, 0x03ff, phozon_snd_sharedram_w },            /* shared RAM with the main CPU */
  143.     { 0xe000, 0xffff, MWA_ROM },                        /* ROM */
  144.     { -1 }                                                /* end of table */
  145. };
  146.  
  147. /* The dipswitches and player inputs are not memory mapped, they are handled by an I/O chip. */
  148. INPUT_PORTS_START( phozon )
  149.     PORT_START  /* DSW0 */
  150.     PORT_DIPNAME( 0x07, 0x00, DEF_STR( Coin_A ) )
  151.     PORT_DIPSETTING(    0x07, DEF_STR( 3C_1C ) )
  152.     PORT_DIPSETTING(    0x05, DEF_STR( 2C_1C ) )
  153.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  154.     PORT_DIPSETTING(    0x06, DEF_STR( 2C_3C ) )
  155.     PORT_DIPSETTING(    0x01, DEF_STR( 1C_2C ) )
  156.     PORT_DIPSETTING(    0x02, DEF_STR( 1C_3C ) )
  157.     PORT_DIPSETTING(    0x03, DEF_STR( 1C_6C ) )
  158.     PORT_DIPSETTING(    0x04, DEF_STR( 1C_7C ) )
  159.     PORT_DIPNAME( 0x18, 0x00, DEF_STR( Lives ) )
  160.     PORT_DIPSETTING(    0x10, "1" )
  161.     PORT_DIPSETTING(    0x00, "3" )
  162.     PORT_DIPSETTING(    0x08, "4" )
  163.     PORT_DIPSETTING(    0x18, "5" )
  164.     PORT_DIPNAME( 0x60, 0x00, DEF_STR( Coin_B ) )
  165.     PORT_DIPSETTING(    0x40, DEF_STR( 2C_1C ) )
  166.     PORT_DIPSETTING(    0x00, DEF_STR( 1C_1C ) )
  167.     PORT_DIPSETTING(    0x60, DEF_STR( 2C_3C ) )
  168.     PORT_DIPSETTING(    0x20, DEF_STR( 1C_2C ) )
  169.  
  170.     PORT_START  /* DSW1 */
  171.     PORT_DIPNAME( 0x07, 0x00, DEF_STR( Difficulty ) )
  172.     PORT_DIPSETTING(    0x00, "0" )
  173.     PORT_DIPSETTING(    0x01, "1" )
  174.     PORT_DIPSETTING(    0x02, "2" )
  175.     PORT_DIPSETTING(    0x03, "3" )
  176.     PORT_DIPSETTING(    0x04, "4" )
  177.     PORT_DIPSETTING(    0x05, "5" )
  178.     PORT_DIPSETTING(    0x06, "6" )
  179.     PORT_DIPSETTING(    0x07, "7" )
  180.     PORT_SERVICE( 0x08, IP_ACTIVE_HIGH )
  181. /* Todo: those are different for 4 and 5 lives */
  182.     PORT_DIPNAME( 0xc0, 0x00, DEF_STR( Bonus_Life ) )
  183.     PORT_DIPSETTING(    0xc0, "20k 80k" )
  184.     PORT_DIPSETTING(    0x40, "30k 60k" )
  185.     PORT_DIPSETTING(    0x80, "30k 120k and every 120k" )
  186.     PORT_DIPSETTING(    0x00, "30k 100k" )
  187.  
  188.     PORT_START  /* IN0 */
  189.     PORT_BIT_IMPULSE(   0x01, IP_ACTIVE_HIGH, IPT_START1, 1 )
  190.     PORT_BIT_IMPULSE(   0x02, IP_ACTIVE_HIGH, IPT_START2, 1 )
  191.     PORT_BIT_IMPULSE(   0x10, IP_ACTIVE_HIGH, IPT_COIN1, 1 )
  192.     PORT_BIT_IMPULSE(   0x20, IP_ACTIVE_HIGH, IPT_COIN2, 1 )
  193.     PORT_BIT( 0x40, IP_ACTIVE_HIGH, IPT_UNKNOWN )
  194.     PORT_DIPNAME( 0x80, 0x00, DEF_STR( Cabinet ) )
  195.     PORT_DIPSETTING(    0x00, DEF_STR( Upright ) )
  196.     PORT_DIPSETTING(    0x80, DEF_STR( Cocktail ) )
  197.  
  198.     PORT_START  /* IN1 */
  199.     PORT_BIT(   0x01, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY )
  200.     PORT_BIT(   0x02, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY )
  201.     PORT_BIT(   0x04, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY )
  202.     PORT_BIT(   0x08, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY )
  203.     PORT_BIT(   0x10, IP_ACTIVE_HIGH, IPT_JOYSTICK_UP    | IPF_8WAY | IPF_PLAYER2 )
  204.     PORT_BIT(   0x20, IP_ACTIVE_HIGH, IPT_JOYSTICK_RIGHT | IPF_8WAY | IPF_PLAYER2 )
  205.     PORT_BIT(   0x40, IP_ACTIVE_HIGH, IPT_JOYSTICK_DOWN  | IPF_8WAY | IPF_PLAYER2 )
  206.     PORT_BIT(   0x80, IP_ACTIVE_HIGH, IPT_JOYSTICK_LEFT  | IPF_8WAY | IPF_PLAYER2 )
  207.  
  208.     PORT_START  /* IN2 */
  209.     PORT_BIT_IMPULSE( 0x01, IP_ACTIVE_HIGH, IPT_BUTTON1, 1 )
  210.     PORT_BITX(  0x02, IP_ACTIVE_HIGH, IPT_BUTTON1, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  211.     PORT_BIT_IMPULSE( 0x04, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2, 1 )
  212.     PORT_BITX(  0x08, IP_ACTIVE_HIGH, IPT_BUTTON1 | IPF_PLAYER2, 0, IP_KEY_PREVIOUS, IP_JOY_PREVIOUS )
  213. INPUT_PORTS_END
  214.  
  215. static struct GfxLayout charlayout =
  216. {
  217.     8,8,            /* 8*8 characters */
  218.     256,            /* 256 characters */
  219.     2,                /* 2 bits per pixel */
  220.     { 0, 4 },
  221.     { 8*8+0, 8*8+1, 8*8+2, 8*8+3, 0, 1, 2, 3 },   /* bits are packed in groups of four */
  222.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },   /* characters are rotated 90 degrees */
  223.     16*8            /* every char takes 16 bytes */
  224. };
  225.  
  226. static struct GfxLayout spritelayout =
  227. {
  228.     16,16,                                         /* 16*16 sprites */
  229.     128,                                           /* 128 sprites */
  230.     2,                                             /* 2 bits per pixel */
  231.     { 0, 4 },
  232.     { 0, 1, 2, 3, 8*8, 8*8+1, 8*8+2, 8*8+3,
  233.         16*8+0, 16*8+1, 16*8+2, 16*8+3, 24*8+0, 24*8+1, 24*8+2, 24*8+3 },
  234.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8,
  235.         32*8, 33*8, 34*8, 35*8, 36*8, 37*8, 38*8, 39*8 },
  236.     64*8                                           /* every sprite takes 64 bytes */
  237. };
  238.  
  239. static struct GfxLayout spritelayout8 =
  240. {
  241.     8,8,                                         /* 16*16 sprites */
  242.     512,                                           /* 128 sprites */
  243.     2,                                             /* 2 bits per pixel */
  244.     { 0, 4 },
  245.     { 0, 1, 2, 3, 8*8, 8*8+1, 8*8+2, 8*8+3 },
  246.     { 0*8, 1*8, 2*8, 3*8, 4*8, 5*8, 6*8, 7*8 },
  247.     16*8                                           /* every sprite takes 64 bytes */
  248. };
  249.  
  250. static struct GfxDecodeInfo gfxdecodeinfo[] =
  251. {
  252.     { REGION_GFX1, 0, &charlayout,       0, 64 },
  253.     { REGION_GFX2, 0, &charlayout,       0, 64 },
  254.     { REGION_GFX3, 0, &spritelayout,  64*4, 64 },
  255.     { REGION_GFX3, 0, &spritelayout8, 64*4, 64 },
  256.     { -1 } /* end of table */
  257. };
  258.  
  259. static struct namco_interface namco_interface =
  260. {
  261.     23920,    /* sample rate (approximate value) */
  262.     8,        /* number of voices */
  263.     100,    /* playback volume */
  264.     REGION_SOUND1    /* memory region */
  265. };
  266.  
  267. static struct MachineDriver machine_driver_phozon =
  268. {
  269.     /* basic machine hardware  */
  270.     {
  271.         {
  272.             CPU_M6809,            /* MAIN CPU */
  273.             1536000,            /* same as Gaplus? */
  274.             readmem_cpu1,writemem_cpu1,0,0,
  275.             interrupt,1
  276.         },
  277.         {
  278.             CPU_M6809,            /* SUB CPU */
  279.             1536000,            /* same as Gaplus? */
  280.             readmem_cpu2,writemem_cpu2,0,0,
  281.             interrupt,1
  282.         },
  283.         {
  284.             CPU_M6809,            /* SOUND CPU */
  285.             1536000,            /* same as Gaplus? */
  286.             readmem_cpu3,writemem_cpu3,0,0,
  287.             interrupt,1
  288.         },
  289.     },
  290.     60, DEFAULT_60HZ_VBLANK_DURATION,    /* frames per second, vblank duration */
  291.     100,    /* a high value to ensure proper synchronization of the CPUs */
  292.     phozon_init_machine,    /* init machine routine */
  293.  
  294.     /* video hardware */
  295.     36*8, 28*8, { 0*8, 36*8-1, 0*8, 28*8-1 },
  296.     gfxdecodeinfo,
  297.     256,
  298.     64*4+64*8,
  299.     phozon_vh_convert_color_prom,
  300.     VIDEO_TYPE_RASTER,
  301.     0,
  302.     phozon_vh_start,
  303.     phozon_vh_stop,
  304.     phozon_vh_screenrefresh,
  305.  
  306.     /* sound hardware */
  307.     0,0,0,0,
  308.     {
  309.         {
  310.             SOUND_NAMCO,
  311.             &namco_interface
  312.         }
  313.     }
  314. };
  315.  
  316.  
  317.  
  318. ROM_START( phozon )
  319.     ROM_REGION( 0x10000, REGION_CPU1 )     /* 64k for code for the MAIN CPU  */
  320.     ROM_LOAD( "6e.rom", 0x8000, 0x2000, 0xa6686af1 )
  321.     ROM_LOAD( "6h.rom", 0xa000, 0x2000, 0x72a65ba0 )
  322.     ROM_LOAD( "6c.rom", 0xc000, 0x2000, 0xf1fda22e )
  323.     ROM_LOAD( "6d.rom", 0xe000, 0x2000, 0xf40e6df0 )
  324.  
  325.     ROM_REGION( 0x10000, REGION_CPU2 )     /* 64k for the SUB CPU */
  326.     ROM_LOAD( "9r.rom", 0xe000, 0x2000, 0x5d9f0a28 )
  327.  
  328.     ROM_REGION( 0x10000, REGION_CPU3 )     /* 64k for the SOUND CPU */
  329.     ROM_LOAD( "3b.rom", 0xe000, 0x2000, 0x5a4b3a79 )
  330.  
  331.     ROM_REGION( 0x1000, REGION_GFX1 | REGIONFLAG_DISPOSE )
  332.     ROM_LOAD( "7j.rom", 0x0000, 0x1000, 0x27f9db5b ) /* characters (set 1) */
  333.  
  334.     ROM_REGION( 0x1000, REGION_GFX2 | REGIONFLAG_DISPOSE )
  335.     ROM_LOAD( "8j.rom", 0x0000, 0x1000, 0x15b12ef8 ) /* characters (set 2) */
  336.  
  337.     ROM_REGION( 0x2000, REGION_GFX3 | REGIONFLAG_DISPOSE )
  338.     ROM_LOAD( "5t.rom", 0x0000, 0x2000, 0xd50f08f8 ) /* sprites */
  339.  
  340.     ROM_REGION( 0x0520, REGION_PROMS )
  341.     ROM_LOAD( "red.prm",     0x0000, 0x0100, 0xa2880667 ) /* red palette ROM (4 bits) */
  342.     ROM_LOAD( "green.prm",   0x0100, 0x0100, 0xd6e08bef ) /* green palette ROM (4 bits) */
  343.     ROM_LOAD( "blue.prm",    0x0200, 0x0100, 0xb2d69c72 ) /* blue palette ROM (4 bits) */
  344.     ROM_LOAD( "chr.prm",     0x0300, 0x0100, 0x429e8fee ) /* characters */
  345.     ROM_LOAD( "sprite.prm",  0x0400, 0x0100, 0x9061db07 ) /* sprites */
  346.     ROM_LOAD( "palette.prm", 0x0500, 0x0020, 0x60e856ed ) /* palette (unused?) */
  347.  
  348.     ROM_REGION( 0x0100, REGION_SOUND1 )    /* sound PROMs */
  349.     ROM_LOAD( "sound.prm", 0x0000, 0x0100, 0xad43688f )
  350. ROM_END
  351.  
  352.  
  353.  
  354. GAMEX( 1983, phozon, 0, phozon, phozon, 0, ROT90, "Namco", "Phozon", GAME_NO_COCKTAIL )
  355.